package com.xing.mapper;

import com.xing.domain.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@Repository
public class DepartmentMapper {
    //模拟数据
    private static Map<Integer, Department> dept = null;
    static {
        dept = new HashMap<Integer,Department>(); //创建一个部门表
        dept.put(101,new Department(101,"研发部"));
        dept.put(102,new Department(102,"财务部"));
        dept.put(103,new Department(103,"运维部"));
        dept.put(104,new Department(104,"后期部"));
    }

    //获取所有部门信息
    public Collection<Department> getDepartments(){
        return dept.values();
    }
    //通过id获取部门
    public Department getDepartmentById(Integer id){
        return dept.get(id);
    }
}
